#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWebSocketServer>
#include <QWebSocket>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void AppendLog(QString t);
    void ViewSendText(QString t);
    void ViewRecvText(QString t);
    typedef enum {
        DATA_TEXT,
        DATA_HEX,
    }DATA_MODE;

private:
    void ClientChange();

signals:
    void PingClient(QByteArray data);


public slots:
    void newConnection();
    void RemoveClient();
    void textFrameReceived(QString a, bool b);
    void textMessageReceived(QString a);
    void binaryFrameReceived(QByteArray a, bool b);
    void binaryMessageReceived(QByteArray a);
    void ClientHasPong(quint64, QByteArray);
    void onPingTimeout();
    void on_pushButton_snd_clicked();
    void on_comboBox_currentIndexChanged(const QString &arg1);
    void on_comboBox_type_currentIndexChanged(int index);
    void on_pushButton_clicked();
    void on_pushButton_snd_clear_clicked();
    void on_pushButton_log_clear_clicked();

private:
    Ui::MainWindow *ui;
    QWebSocket *mCurrentWeb;
    QWebSocketServer *wsServer;
    QList<QWebSocket*> ClientList;
    DATA_MODE dataMode;
    bool bShowPing;
    QTimer pingTmr;
};
#endif // MAINWINDOW_H
